//
//  MQVideoSocietyDetailViewController.m
//  MQ
//
//  Created by lanou on 15/10/27.
//  Copyright © 2015年 徐永祥. All rights reserved.
//

#import "MQVideoSocietyDetailViewController.h"
#import "MQSocietyDetailCell.h"
#import "PKRequestManager.h"
#import "MQSocietyHeaderView.h"
#import <MediaPlayer/MediaPlayer.h>
#import "MQSocietyBodyList.h"
#import "MQVideoFooterView.h"
#import "UMSocial.h"
#import "MQPopupView.h"
#import "LewPopupViewAnimationDrop.h"
@interface MQVideoSocietyDetailViewController ()<UITableViewDelegate,UITableViewDataSource,UMSocialUIDelegate>
@property (nonatomic, strong)UITableView * socityTableView;
@property (nonatomic, strong)UIScrollView * tableScrollView;
@property (nonatomic, strong)NSMutableArray * relativeArr;
@property (nonatomic, strong)MQSocietyHeaderView * headerView;
@property (nonatomic, strong)MPMoviePlayerController * player;
@property (nonatomic, strong)UIButton * backButton;
@property (nonatomic, strong)UITableView * hotTableView;
@property (nonatomic, strong)NSMutableArray * hotArr;
@property (nonatomic, strong)UITableView * rankTableView;
@property (nonatomic, strong)NSMutableArray * rankArr;
@property (nonatomic, assign)float contentOff_y;
@property (nonatomic, strong)MQVideoFooterView * footerView;
@property (nonatomic, assign)NSInteger index;
@property (nonatomic, assign)NSInteger hotIndex;
@property (nonatomic, copy)NSString * urlStr;
@end

@implementation MQVideoSocietyDetailViewController


-(NSMutableArray *)relativeArr
{
    
    if (_relativeArr == nil) {
        self.relativeArr = [NSMutableArray arrayWithCapacity:0];
    }
    return _relativeArr;
}
-(NSMutableArray *)hotArr
{
    if (_hotArr == nil) {
        self.hotArr = [NSMutableArray arrayWithCapacity:0];
    }
    return _hotArr;
}


-(NSMutableArray *)rankArr
{
    if (_rankArr == nil) {
        self.rankArr = [NSMutableArray arrayWithCapacity:0];
    }
    return _rankArr;
}

-(void)requestData
{

    NSString * url =[NSString stringWithFormat:@"http://vcsp.ifeng.com/vcsp/appData/getGuidRelativeVideoList.do?guid=%@&pageSize=20",self.guid];
    [PKRequestManager requestWithType:GET urlString:url parDic:nil finish:^(NSData *data) {
        NSDictionary * dataDic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:nil];
        NSArray * array = [dataDic objectForKey:@"guidRelativeVideoInfo"];
        for (NSDictionary * dic in array) {
            MQSocietyDetailModel * model = [[MQSocietyDetailModel alloc]init];
            [model setValuesForKeysWithDictionary:dic];
            [self.relativeArr addObject:model];
        }
        [self.socityTableView reloadData];
        
        
        //设置视频URL
        NSArray * files = [array[0] objectForKey:@"files"];
        for (int i = 0 ; i<files.count; i++) {
            
            if ([[[files[i] objectForKey:@"mediaUrl"] substringWithRange:NSMakeRange(((NSString *)[files[i] objectForKey:@"mediaUrl"]).length-3, 3)] isEqualToString:@"mp4"]) {
               
                      _player.contentURL = [NSURL URLWithString:[files[i] objectForKey:@"mediaUrl"]];
                    NSLog(@"%@",[files[i] objectForKey:@"mediaUrl"]);
              
              
                
            }
        }
     
        _player.view.frame =CGRectMake(0, 0, _headerView.pictureView.frame.size.width, _headerView.pictureView.frame.size.height) ;
        _player.fullscreen = NO;
        [_headerView.pictureView addSubview:_player.view];
        _backButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _backButton.frame = CGRectMake(20, 20, 20, 20);
        [_backButton setBackgroundImage:[UIImage imageNamed:@"fanhui"] forState:(UIControlStateNormal)];
        [_player.view addSubview:_backButton];
        [_backButton addTarget:self action:@selector(back) forControlEvents:(UIControlEventTouchUpInside)];
        [_player play];
        
    } error:^(NSError *error) {
        NSLog(@"%@",error);
    }];
    
   
}

//热点请求
-(void)requestHotData
{
[PKRequestManager requestWithType:GET urlString:@"http://vcsp.ifeng.com/vcsp/appData/recommend.do?useType=androidPhone&channelId=hotList&pageSize=10&adapterNo=6.8.0" parDic:nil finish:^(NSData *data) {
    NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:nil];
    NSArray * array = [dic objectForKey:@"bodyList"];
    for (NSDictionary * hotDic in array) {
        MQSocietyHeadModel * model = [[MQSocietyHeadModel alloc]init];
        [model setValuesForKeysWithDictionary:hotDic];
        [self.hotArr addObject:model];
    }
    [_hotTableView reloadData];
    
    
} error:^(NSError *error) {
    NSLog(@"%@",error);
}];
    
}

//排行请求
-(void)requestRankData
{

    [PKRequestManager requestWithType:GET urlString:@"http://vcsp.ifeng.com/vcsp/appData/recommend.do?useType=androidPhone&channelId=rankList&pageSize=10&adapterNo=6.8.0" parDic:nil finish:^(NSData *data) {
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:nil];
        NSArray * array = [dic objectForKey:@"bodyList"];
        for (NSDictionary * hotDic in array) {
            MQSocietyHeadModel * model = [[MQSocietyHeadModel alloc]init];
            [model setValuesForKeysWithDictionary:hotDic];
            [self.rankArr addObject:model];
        }
        [_rankTableView reloadData];
        
        
    } error:^(NSError *error) {
        NSLog(@"%@",error);
    }];

    
}
    

-(void)changeTableView:(UIButton *)button
{

    switch (button.tag-1000) {
        case 0:
        {
            [_headerView.reButton setTitleColor:[UIColor redColor] forState:(UIControlStateNormal)];
            [_headerView.hotButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
            [_headerView.rankButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
            _tableScrollView.contentOffset = CGPointMake(0, 0);
            
        }
            break;
            case 1:
        {
            [_headerView.reButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
            [_headerView.hotButton setTitleColor:[UIColor redColor] forState:(UIControlStateNormal)];
            [_headerView.rankButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
            _tableScrollView.contentOffset = CGPointMake(screen_width, 0);
        }
            break;
            
            
            case 2:
        {
            [_headerView.reButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
            [_headerView.hotButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
            [_headerView.rankButton setTitleColor:[UIColor redColor] forState:(UIControlStateNormal)];
            _tableScrollView.contentOffset = CGPointMake(2*screen_width, 0);
        }
            break;
    }
    
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{

    UIButton * button = (UIButton *)[self.view viewWithTag:_tableScrollView.contentOffset.x/screen_width+1000];
    [self changeTableView:button];
   
    
}
//添加底视图的方法
-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
 _contentOff_y = scrollView.contentOffset.y;
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{

    if (scrollView.contentOffset.y>_contentOff_y) {
        _footerView.frame = CGRectMake(0, -100, 0, 0);
        [self.view addSubview:_footerView];
    }
    else
    {
        _footerView.frame = CGRectMake(0, screen_height-50, screen_width, 50);
    }
   
    
    [((UIButton *)_footerView.backGroundView.subviews[0]) addTarget:self action:@selector(share:) forControlEvents:(UIControlEventTouchUpInside)];
    [((UIButton *)_footerView.backGroundView.subviews[1]) addTarget:self action:@selector(shezhi:) forControlEvents:(UIControlEventTouchUpInside)];
    
}

-(void)shareToWeb
{

    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"561b79fde0f55ac7c00016bf"
                                      shareText:self.urlStr
                                     shareImage:nil
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren,UMShareToDouban,UMShareToFacebook,nil]
                                       delegate:self];

    
}


-(void)share:(UIButton *)button
{

    if (button.tag%10000==0) {
         NSIndexPath * indexPath = [NSIndexPath indexPathForRow:button.tag/10000 inSection:0];
       
        MQSocietyDetailModel * model = self.relativeArr[indexPath.row];
        NSArray * files = model.files;
        for (int i = 0 ; i<files.count; i++) {
            
            if ([[[files[i] objectForKey:@"mediaUrl"] substringWithRange:NSMakeRange(((NSString *)[files[i] objectForKey:@"mediaUrl"]).length-3, 3)] isEqualToString:@"mp4"]) {
                
              self.urlStr =  [files[i] objectForKey:@"mediaUrl"];
                NSLog(@"%@",[files[i] objectForKey:@"mediaUrl"]);
                
                
                
            }
        }
        [self shareToWeb];
       
    }
    else if (button.tag%10000==screen_width)
    {
        NSIndexPath * indexPath = [NSIndexPath indexPathForRow:button.tag/10000 inSection:0];
        
        MQSocietyHeadModel * model = self.hotArr[indexPath.row];
        NSString * url =[NSString stringWithFormat:@"http://vcsp.ifeng.com/vcsp/appData/videoGuid.do?guid=%@",model.memberItem.guid];
            [PKRequestManager requestWithType:GET urlString:url parDic:nil finish:^(NSData *data) {
                NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:nil];
                NSDictionary * videoDic = [dic objectForKey:@"videoFiles"];
                for (NSDictionary * dict in videoDic) {
                    if ([[videoDic[dict][@"mediaUrl"] substringWithRange:NSMakeRange(((NSString *)videoDic[dict][@"mediaUrl"]).length-3, 3)] isEqualToString:@"mp4"]) {
                        dispatch_async(dispatch_get_main_queue(), ^{
                            self.urlStr = videoDic[dict][@"mediaUrl"];
                        });
                        
                        
                        
                    }
                }
                
                [self shareToWeb];
                
            } error:^(NSError *error) {
                NSLog(@"%@",error);
            }];
     
            
      
    }
   
   else
   {
       NSIndexPath * indexPath = [NSIndexPath indexPathForRow:button.tag/10000 inSection:0];
       
       MQSocietyHeadModel * model = self.rankArr[indexPath.row];
       NSString * url =[NSString stringWithFormat:@"http://vcsp.ifeng.com/vcsp/appData/videoGuid.do?guid=%@",model.memberItem.guid];
       [PKRequestManager requestWithType:GET urlString:url parDic:nil finish:^(NSData *data) {
           NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:nil];
           NSDictionary * videoDic = [dic objectForKey:@"videoFiles"];
           for (NSDictionary * dict in videoDic) {
               if ([[videoDic[dict][@"mediaUrl"] substringWithRange:NSMakeRange(((NSString *)videoDic[dict][@"mediaUrl"]).length-3, 3)] isEqualToString:@"mp4"]) {
                   dispatch_async(dispatch_get_main_queue(), ^{
                       self.urlStr = videoDic[dict][@"mediaUrl"];
                   });
                   
                   
                   
               }
               
               

           }
           
           [self shareToWeb];

       } error:^(NSError *error) {
           NSLog(@"%@",error);
       }];
       
       
       
   }
    
}

-(void)shezhi:(UIButton *)button
{
    MQPopupView *view = [MQPopupView defaultPopupView];
    view.parentVC = self;
    [self lew_presentPopupView:view animation:[LewPopupViewAnimationDrop new] dismissed:^{
        NSLog(@"动画结束");
        
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.index = 0;
    //播放器页面
    _headerView = [[MQSocietyHeaderView alloc]initWithFrame:CGRectMake(0, 0, screen_width, 230)];
     [self.view addSubview:_headerView];
      _headerView.reButton.tag=1000;
    [_headerView.reButton addTarget:self action:@selector(changeTableView:) forControlEvents:(UIControlEventTouchUpInside)];
    [_headerView.reButton setTitleColor:[UIColor redColor] forState:(UIControlStateNormal)];
    _headerView.hotButton.tag=1001;
    [_headerView.hotButton addTarget:self action:@selector(changeTableView:) forControlEvents:(UIControlEventTouchUpInside)];
    _headerView.rankButton.tag=1002;
    [_headerView.rankButton addTarget:self action:@selector(changeTableView:) forControlEvents:(UIControlEventTouchUpInside)];
    
    //大得scrollView装载三个tableView
    _tableScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 250, screen_width, screen_height-230)];
    _tableScrollView.contentSize = CGSizeMake(screen_width *3, 0);
    _tableScrollView.pagingEnabled = YES;
    _tableScrollView.delegate = self;
    [self.view addSubview:_tableScrollView];
   
   // 相关
    _socityTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, screen_width, screen_height-250) style:(UITableViewStylePlain)];
       _socityTableView.delegate = self;
    _socityTableView.dataSource = self;
    _socityTableView.tag = 100;
    [self.tableScrollView addSubview:_socityTableView];
    [_socityTableView registerClass:[MQSocietyDetailCell class] forCellReuseIdentifier:@"cell"];
    [self requestData];
    self.socityTableView.rowHeight = 120;
   //初始化播放器
    _player = [[MPMoviePlayerController alloc]init];
    //热点
    _hotTableView =[[UITableView alloc]initWithFrame:CGRectMake(screen_width, 0, screen_width, screen_height-250) style:(UITableViewStylePlain)];
    _hotTableView.delegate = self;
    _hotTableView.dataSource = self;
    _hotTableView.tag = 200;
    _hotTableView.rowHeight = 120;
//    _hotTableView.backgroundColor = [UIColor clearColor];
//    _tableScrollView.backgroundColor = [UIColor clearColor];
    [_hotTableView registerClass:[MQSocietyDetailCell class] forCellReuseIdentifier:@"hot"];
    [self.tableScrollView addSubview:_hotTableView];
    [self requestHotData];
    
    
   //排行
    _rankTableView = [[UITableView alloc]initWithFrame:CGRectMake(2*screen_width, 0, screen_width, screen_height-250) style:(UITableViewStylePlain)];
    _rankTableView.delegate = self;
    _rankTableView.dataSource = self;
    _rankTableView.rowHeight = 120;
    [_rankTableView registerClass:[MQSocietyDetailCell class] forCellReuseIdentifier:@"rank"];
    [self.tableScrollView addSubview:_rankTableView];
    [self requestRankData];
    _footerView = [[MQVideoFooterView alloc]init];
    _footerView.frame = CGRectMake(0, -100, 0, 0);
    [self.view addSubview:_footerView];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(enterFullScreen) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(exitFullScreen) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
}

-(void)enterFullScreen
{

    
    self.tableScrollView.frame = CGRectZero;
    self.headerView.backGroundView.frame = CGRectZero;
    self.headerView.reButton.frame = CGRectZero;
    self.headerView.hotButton.frame = CGRectZero;
    self.headerView.rankButton.frame = CGRectZero;
    self.socityTableView.frame = CGRectZero;
    self.hotTableView.frame = CGRectZero;
    self.rankTableView.frame = CGRectZero;
    UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(exitFullScreen)];
    recognizer.numberOfTapsRequired = 2;
    [_player.view addGestureRecognizer:recognizer];
}

-(void)exitFullScreen
{
    self.tableScrollView.frame =CGRectMake(0, 250, screen_width, screen_height-230);
    self.headerView.backGroundView.frame=CGRectMake(0, 200, screen_width, 30);
   
   
    self.headerView.reButton.frame= CGRectMake(0, 5, screen_width/3, 20);
    self.headerView.hotButton.frame= CGRectMake(screen_width/3, 5, screen_width/3, 20) ;
    self.headerView.rankButton.frame= CGRectMake(screen_width/3*2, 5, screen_width/3, 20) ;
    self.socityTableView.frame=CGRectMake(0, 0, screen_width, screen_height-250);
    self.hotTableView.frame= CGRectMake(screen_width, 0, screen_width, screen_height-250);
    self.rankTableView.frame=  CGRectMake(2*screen_width, 0, screen_width, screen_height-250);
    _player.fullscreen = NO;
}


-(void)back
{
    [_player.view removeFromSuperview];
    [_player stop];
        [UIView animateWithDuration:2.0 animations:^{
            [self dismissViewControllerAnimated:YES completion:nil];
        }];

    
    [[NSNotificationCenter defaultCenter]postNotificationName:@"table" object:nil];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    if (tableView.tag==100) {
        return self.relativeArr.count;
    }
    else
    {
        if (tableView.tag==200) {
            return self.hotArr.count;
        }
        else
        {
            return self.rankArr.count;
        }
    }
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

   
    if (tableView.tag == 100) {
        
        MQSocietyDetailCell * cell = [self.socityTableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
        MQSocietyDetailModel * model = self.relativeArr[indexPath.row];
        if (indexPath.row==self.index) {
           
           cell.titleLabel.textColor = [UIColor redColor];
        }
        
        else
        {
                 cell.titleLabel.textColor = [UIColor blackColor];
           
        }
         cell.pictureView.image = [UIImage imageNamed:@""];
        [cell configCellWithModel:model];
        return cell;
    }
    else
    {
    
        if (tableView.tag==200) {
            MQSocietyDetailCell * cell = [self.hotTableView dequeueReusableCellWithIdentifier:@"hot" forIndexPath:indexPath];
            MQSocietyHeadModel * model = self.hotArr[indexPath.row];
            cell.pictureView.image = [UIImage imageNamed:@""];
           
            if (model.isHotSelect==YES) {
                cell.titleLabel.textColor = [UIColor redColor];
            }
            else
            {
                cell.titleLabel.textColor = [UIColor blackColor];
            }

            [cell configCellWithHotModel:model];

            return cell;

        }
        else
        {
            MQSocietyDetailCell * cell = [self.rankTableView dequeueReusableCellWithIdentifier:@"rank" forIndexPath:indexPath];
            MQSocietyHeadModel * model = self.rankArr[indexPath.row];
            cell.pictureView.image = [UIImage imageNamed:@""];
            if (model.isRankSelect==YES) {
                cell.titleLabel.textColor = [UIColor redColor];
            }
            else
            {
                cell.titleLabel.textColor = [UIColor blackColor];
            }

            [cell configCellWithHotModel:model];
            return cell;
        }
    }
    
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
   
     ((UIButton *)_footerView.backGroundView.subviews[0]).tag = 10000*indexPath.row + self.tableScrollView.contentOffset.x;
    
    if (tableView.tag==100) {
       
        MQSocietyDetailCell * cell = [tableView cellForRowAtIndexPath:indexPath];
        cell.titleLabel.textColor = [UIColor redColor];
        [_player stop];
        MQSocietyDetailModel * model = self.relativeArr[indexPath.row];
        self.index = indexPath.row;

       
        if (indexPath.row !=0) {
            NSIndexPath * firstIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
            MQSocietyDetailCell * firstCell = [tableView cellForRowAtIndexPath:firstIndexPath];
           firstCell.titleLabel.textColor = [UIColor blackColor];
        }
        
               NSArray * files = model.files;
        for (int i = 0 ; i<files.count; i++) {
            
            if ([[[files[i] objectForKey:@"mediaUrl"] substringWithRange:NSMakeRange(((NSString *)[files[i] objectForKey:@"mediaUrl"]).length-3, 3)] isEqualToString:@"mp4"]) {
                
                _player.contentURL = [NSURL URLWithString:[files[i] objectForKey:@"mediaUrl"]];
                NSLog(@"%@",[files[i] objectForKey:@"mediaUrl"]);
                
                
                
            }
        }
        [_player play];
    }
    
    else
    {
        NSIndexPath * firstIndexPath = [NSIndexPath indexPathForRow:self.index inSection:0];
        MQSocietyDetailCell * firstCell = [self.socityTableView cellForRowAtIndexPath:firstIndexPath];
        
        
        firstCell.titleLabel.textColor = [UIColor blackColor];
        if (tableView.tag==200) {
            MQSocietyDetailCell * cell = [tableView cellForRowAtIndexPath:indexPath];
            cell.titleLabel.textColor = [UIColor redColor];

             MQSocietyHeadModel * model = self.hotArr[indexPath.row];
            NSString * url =[NSString stringWithFormat:@"http://vcsp.ifeng.com/vcsp/appData/videoGuid.do?guid=%@",model.memberItem.guid];
            [PKRequestManager requestWithType:GET urlString:url parDic:nil finish:^(NSData *data) {
                NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:nil];
                NSDictionary * videoDic = [dic objectForKey:@"videoFiles"];
                for (NSDictionary * dict in videoDic) {
                if ([[videoDic[dict][@"mediaUrl"] substringWithRange:NSMakeRange(((NSString *)videoDic[dict][@"mediaUrl"]).length-3, 3)] isEqualToString:@"mp4"]) {
                            dispatch_async(dispatch_get_main_queue(), ^{
                                [_player stop];
                                _player.contentURL = [NSURL URLWithString:videoDic[dict][@"mediaUrl"]];
                                [_player play];
                            });
                        
            
                    
                }
                }
            } error:^(NSError *error) {
                NSLog(@"%@",error);
            }];
        }
        else
        {
            MQSocietyDetailCell * cell = [tableView cellForRowAtIndexPath:indexPath];
            cell.titleLabel.textColor = [UIColor redColor];

            MQSocietyHeadModel * model = self.rankArr[indexPath.row];
           
            NSString * url =[NSString stringWithFormat:@"http://vcsp.ifeng.com/vcsp/appData/videoGuid.do?guid=%@",model.memberItem.guid];
            [PKRequestManager requestWithType:GET urlString:url parDic:nil finish:^(NSData *data) {
                NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:nil];
                NSDictionary * videoDic = [dic objectForKey:@"videoFiles"];
                for (NSDictionary * dict in videoDic) {
                    if ([[videoDic[dict][@"mediaUrl"] substringWithRange:NSMakeRange(((NSString *)videoDic[dict][@"mediaUrl"]).length-3, 3)] isEqualToString:@"mp4"]) {
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [_player stop];
                            _player.contentURL = [NSURL URLWithString:videoDic[dict][@"mediaUrl"]];
                            [_player play];
                        });
                        
                        
                        
                    }

                }
            } error:^(NSError *error) {
                NSLog(@"%@",error);
            }];

        }
    }

}

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{

    
    
        MQSocietyDetailCell * cell = [tableView cellForRowAtIndexPath:indexPath];
            cell.titleLabel.textColor = [UIColor blackColor];
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
